< previous page page_144 next page >

Page 144
Now, heres a practical example using the Employee Information form. Check out the standard module Vars.bas to see the following declaration:
9f31265bb40b592b1929e18a47ab28e5.gif
Public Type Employee_Type
   strSSN As String
   strFirst As String
   strLast As String
   strStreet As String
   strCity As String
   strState As String
   strZip As String
   curSalary As Currency
   boolBonus As Boolean
End Type
As you can see, this data type is now made up of many different string variables, a currency variable, and a Boolean variable. However, each element can only be referenced through a variable declared to be of type Employee_Type.
The Type declaration, by itself, is just a template of what this data type will look like. To use it, you must declare a Private or Public variable as Employee_Type:
9f31265bb40b592b1929e18a47ab28e5.gif
Private mtypEmp As Employee_Type
After youve created this new variable, you can set the individual elements of this type, just like you set properties for a control or a form:
9f31265bb40b592b1929e18a47ab28e5.gif
mtypEmp.strFirst = "Bill"
mtypEmp.strLast = "Gates"
mtypEmp.curSalary = 1000000
mtypEmp.boolBonus = True
Lets take the Employee Information form you created in a previous chapter and load the data from the form into this structure (see Figure 7.3).

 
< previous page page_144 next page >

If you like this book, buy it!